﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Telerik.Web.UI;

namespace BSCMFF.Web.Pages
{
    public partial class QuestionaireSettings : BSCMFF.Core.MultiLanguagePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            QuestionClass qc1 = new QuestionClass("one");
            QuestionClass qc2 = new QuestionClass("duo");

            List<QuestionClass> qcs = new List<QuestionClass>();

            qcs.Add(qc1);
            qcs.Add(qc2);

            RadGrid1.DataSource = qcs;
            RadGrid1.DataBind();
        }

        protected void ButtonApplyAnswers_Click(object sender, EventArgs e)
        {
            //RadGrid1.e
            //GridTemplateColumn tc = (GridTemplateColumn)RadGrid1.MasterTableView.Columns[0];
            //tc.Owner.Columns.Remove(tc);
            RadioButton rb = new RadioButton();
            rb.GroupName="gn";
            rb.Text = RadTextBox5.Text;

            foreach(GridDataItem item in RadGrid1.MasterTableView.Items)
            {
                if (((CheckBox)item.Cells[3].Controls[1]).Checked)
                {
                    item.Cells[2].Controls.Add(rb);
                    ((RadTextBox)item.Cells[2].Controls[1]).Text = RadTextBox5.Text;
                }
            }
            //RadGrid1.MasterTableView.Items[1].Controls[2].Controls[3].GetType()
        }

        protected void CheckBoxQuestion_Changed(object sender, EventArgs e)
        {
            CheckBox chb = (CheckBox)sender;
            if (chb.Checked && ViewState[chb.ClientID] == null)
            {
                ViewState[chb.ClientID] = true;
            }
            else
            {
                if (!chb.Checked)
                {
                    ViewState[chb.ClientID] = null;
                }
            }

            lab.Text = chb.ClientID + "  " + ViewState[chb.ClientID].ToString();
        }

        protected void bu_Click(object sender, EventArgs e)
        {
            //lab.Text = ViewState[chb.ClientID].ToString();
        }

    }

    public class QuestionClass
    {
        private string question;

        public string Question 
        { 
            get 
            {
                return question;
            }
            set
            {
                question = value;
            }
        }

        public QuestionClass(string q)
        {
            question = q;
        }
    }
}